package huaWei;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

//26支球队，a-z表示 输入格式：例"a-b 3:1" 代表a队3分b队一分
//每一行按格式输入球队得分
//最后按得分从高到低顺序，艹按顺序，按顺序！！！输出球队对应得分，格式如 a 3,b 1
public class Solution {
	public static Map<Character, Integer> store = new HashMap<Character, Integer>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String temp;
		while(sc.hasNextLine()) {
			if((temp = sc.nextLine()).equals("")) {
				break;
			}
			countScore(temp);
			
		}
		char[] keys = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		int count = 0;
		for(char key:keys) {
			if(count == store.size() -1) {
				System.out.print(key + " " + store.get(key));
				break;
			}
			if(store.containsKey(key)) {
				System.out.print(key + " " + store.get(key) + ",");
			}
			
			count ++;
		}
		
	}

	public static void countScore(String info) {
			String[] infoSpilt = info.split(" ");
			String[] score = infoSpilt[1].split(":");
			int score0 = Integer.parseInt(score[0]);
			int score1 = Integer.parseInt(score[1]);
			if(!store.containsKey(infoSpilt[0].charAt(0))) {
				store.put(infoSpilt[0].charAt(0), score0);
			}else if(store.containsKey(infoSpilt[0].charAt(0))) {
				int newScore1 = store.get(infoSpilt[0].charAt(0)) + score0;
				store.put(infoSpilt[0].charAt(0), newScore1);	
			}
			if(!store.containsKey(infoSpilt[0].charAt(2))) {
				store.put(infoSpilt[0].charAt(2), score1);
			}else if(store.containsKey(infoSpilt[0].charAt(2))) {
				int newScore2 = store.get(infoSpilt[0].charAt(2)) + score1;
				store.put(infoSpilt[0].charAt(2), newScore2);	
			}	
	}
}
